<script lang="ts" setup>
import { ref } from 'vue'
import {companyInfoGetSwipeSerive} from '@/api/company.js'
import ImageUpload from './ImageUpload.vue';
import { ElMessage } from 'element-plus';
import { baseURL } from '@/utils/request';
interface SwipeItem {  
  id: number;  
  name:string;
  imageUrl: string;  
  // 其他可能需要的属性，如title  
}  
const swipe = ref<SwipeItem[]>([]);
const getSwipeList = async()=>{
  const res =  await companyInfoGetSwipeSerive()
  swipe.value = res.data.data
  ElMessage.success('获取轮播图信息成功！') 
}
getSwipeList()
const changeUrl = (url:string)=>{
   return baseURL + url
}
</script>

<template>
    <div class="wrapped" >
      <h3>提示：点击图片框进行切换首页轮播图</h3>
     <div class="commpany-content">
      <el-form>
        <div v-for="item in swipe" :key="item.id">
        <el-form-item  :label="item.name">
         <ImageUpload :name="item.name"  :imgUrl="changeUrl(item.imageUrl)" />
        </el-form-item>
        </div>

      </el-form>
    </div>
      
    </div>
</template>

<style lang="scss" scoped>
.wrapped{
  .el-form{
            display: flex;
            justify-content: flex-start;
            align-content: flex-start;
            flex-direction: column;
            flex-wrap: wrap;
             height: 540px;
            .el-form-item{
                   width: 350px;
                  height: 160px;
              
            }
        }

}

.avatar-uploader .avatar {
  width: 178px;
  height: 178px;
  display: block;
}
</style>

<style>
.avatar-uploader .el-upload {
  border: 1px dashed var(--el-border-color);
  border-radius: 6px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: var(--el-transition-duration-fast);
}

.avatar-uploader .el-upload:hover {
  border-color: var(--el-color-primary);
}

.el-icon.avatar-uploader-icon {
  font-size: 28px;
  color: #8c939d;
  width: 178px;
  height: 178px;
  text-align: center;
}
</style>
